package com.glorysoft.xztpda.bindingadapter

import android.graphics.Color
import android.widget.LinearLayout
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.glorysoft.xztpda.R
import com.glorysoft.xztpda.entity.LotInfoEntity

/**
 * FileName: LastLotAdapter
 * Author: XJH
 * Date: 2022/5/12 18:30
 * Description:
 * History:
 */
class LastLotAdapter(data: MutableList<LotInfoEntity.LotBean>?) :
    BaseQuickAdapter<LotInfoEntity.LotBean, BaseViewHolder>(R.layout.item_last_lot, data) {

    var index = -1
    override fun convert(helper: BaseViewHolder, item: LotInfoEntity.LotBean) {
        helper.setText(R.id.tvLastLot, item.lotid).setText(R.id.tvLastLotQty, item.mainqty.toString())
        val llLastLotLayout: LinearLayout = helper.getView(R.id.llLastLotLayout)
        if (index == helper.adapterPosition) {
            llLastLotLayout.setBackgroundColor(Color.rgb(248,203,183))
        } else {
            llLastLotLayout.setBackgroundColor(Color.WHITE)
        }
        llLastLotLayout.setOnClickListener {
            index = helper.adapterPosition
            notifyDataSetChanged()
        }
    }


}